package com.qianye.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CommonController {

    @RequestMapping("/")
    public String toLogin() {
        return "login";
    }

    @RequestMapping("/toIndex")
    public String toIndex() {
        return "index";
    }

    @RequestMapping("/toregister")
    public String toRegister() {
        return "register";
    }

    @RequestMapping("/toexpressreject")
    @ResponseBody
    public Integer toExpressReject(@RequestParam("id") Integer id) {
        return id;
    }

    @RequestMapping("/expressreject")
    public String ExpressReject(@RequestParam("id") Integer id, Model model) {
        model.addAttribute("id",id);
        return "customer/expressreject";
    }

    @RequestMapping("/toauth")
    @ResponseBody
    public Integer toauth(@RequestParam("id") Integer id,Model model) {
        return id;
    }

    @RequestMapping("/adddeliver")
    public String toAddDeliver() {
        return "daemon/deliveradd";
    }

    @RequestMapping("/changestatus")
    @ResponseBody
    public Integer changeStatus(@RequestParam("id") Integer id) {
        return id;
    }

    @RequestMapping("/logout")
    public String doLogOut() {
        Subject subject = SecurityUtils.getSubject();
        subject.logout();
        return "redirect:/";
    }
}
